package com.hk.productservice.mapper;


import com.hk.model.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.List;

/**
 * @Author: zhe
 * @Date: 2021/6/19 12:37
 * @Statement: 产品Mapper层接口
 */
public interface ProductMapper extends BaseMapper<Product> {

    @Override
    List<Product> findAll(Product product);

    @Override
    int count(Product product);

    @Override
    Product findById(Integer id);

    List<Product> findByIds(@Param("id") Integer id);

    @Insert("insert into product value " +
                "(null,#{img},#{name},#{detail},#{marketPrice}," +
                "#{platformPrice},#{tMenuId},#{menuId},#{gmtCreate},#{gmtModified})")
    @Override
    int save(Product product);

    @Update("update product set " +
                "img=#{img},name=#{name},detail=#{detail},market_price=#{marketPrice}," +
                "platform_price=#{platformPrice},tmenu_id=#{tMenuId},menu_id=#{menuId},gmt_modified=#{gmtModified}" +
            "where id = #{id} ")
    @Override
    int update(Product product);

    @Delete("delete from product where id = #{id} ")
    @Override
    int delete(Integer id);

}
